<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Class</title>
</head>
<body>
<div id="getAllDiv"></div>
<script>
    class Student{
        constructor(name, address){
            this.name = name
            this.address = address
        }
    }
    
    const student = new Student("tommy", "beijing")
    console.log(student)
    Object.defineProperty(student, 'age', {
        get(){
            console.log(age)
            return age
        },
        set(_age){
            if(_age > 130 || _age<0){
                age = 0
            }
            else{
                age = _age
            }
        }
    })  
    student.age = 35
    console.log(student.age)
    student.age = 150
    console.log(student.age) 
</script>
</body>
</html>